var firstUniqChar = function(s) {
  let len = s.length;
  let table = {};
  for(var i = 0;i < len;i++){
      if(s[i] in table){
          table[s[i]] += 1
      }else{
          table[s[i]] = 1
      }
  }
  for(let key in table){
      if(table[key] === 1){
          return s.indexOf(key);
      }
  }
  return -1

};

var a = firstUniqChar("loveleetcode")
console.log(a);
